import sys
from dataclasses import dataclass, field


@dataclass
class Family:
    home_num: int = 0
    home_seq: int = 0
    people: set = field(default_factory=set)
    avg_num: int = 0
    avg_seq: int = 0

    def __add__(self, other):
        return Family(self.home_num + other.home_num, self.home_seq + other.home_seq,
                      people=(self.people | other.people))

    def __and__(self, other):
        return len(self.people & other.people) != 0


def main():
    x = int(input())
    f = lambda _: _ != -1
    familys: list[Family] = []
    for _ in range(x):
        fam = set()
        s = list(map(int, sys.stdin.readline().strip('\n').split()))
        low, father, mother, child_num, *child, house, sq = s
        fam.add(low)
        fam.update(list(filter(f, [father, mother])) + child)
        family = Family(house, sq, fam)
        familys.append(family)

    single = False
    b = familys
    while not single:
        a = b
        b = []
        single = True
        for i in a:
            added = False
            for index, j in enumerate(b):
                if i & j:
                    added = True
                    single = False
                    b[index] = i + j
                    break
            if not added:
                b.append(i)

    for i in b:
        i.avg_seq = i.home_seq / len(i.people)
        i.avg_num = i.home_num / len(i.people)
    b = list(b)
    b.sort(key=lambda x: (x.avg_seq, -min(x.people)), reverse=True)
    print(len(b))
    for i in b:
        print('%04d %d %.3f %.3f' % (min(i.people), len(i.people), i.avg_num, i.avg_seq))


main()
